/// <reference path="_variables-shared.scss" />
/// <reference path="../lib/bs4/scss/bootstrap.scss" />
/// <reference path="../lib/rfs/_rfs.scss" />


//
// Responsive spacing (replaces standard BS spacing include)
// ----------------------------------------------------------

@mixin spacing-prop($prop, $size, $length, $breakpoint) {
    @if ($size > 3 AND $breakpoint == "xs") {
        @include rfs($length !important, #{$prop});
    }
    @else {
        #{$prop}: $length !important;
    }    
}

@each $breakpoint in map-keys($grid-breakpoints) {
    @include media-breakpoint-up($breakpoint) {
        $infix: breakpoint-infix($breakpoint, $grid-breakpoints);

        @each $prop, $abbrev in (margin: m, padding: p) {
            @each $size, $length in $rfs-spacers {
                .#{$abbrev}#{$infix}-#{$size} {
                    @include spacing-prop(#{$prop}, $size, $length, $breakpoint);
                }
                .#{$abbrev}t#{$infix}-#{$size},
                .#{$abbrev}y#{$infix}-#{$size} {
                    @include spacing-prop(#{$prop}-top, $size, $length, $breakpoint);
                }
                .#{$abbrev}r#{$infix}-#{$size},
                .#{$abbrev}x#{$infix}-#{$size} {
                    @include spacing-prop(#{$prop}-right, $size, $length, $breakpoint);
                }
                .#{$abbrev}b#{$infix}-#{$size},
                .#{$abbrev}y#{$infix}-#{$size} {
                    @include spacing-prop(#{$prop}-bottom, $size, $length, $breakpoint);
                }
                .#{$abbrev}l#{$infix}-#{$size},
                .#{$abbrev}x#{$infix}-#{$size} {
                    @include spacing-prop(#{$prop}-left, $size, $length, $breakpoint);
                }
            }
        }

        // Some special margin utils
        .m#{$infix}-auto { margin: auto !important; }
        .mt#{$infix}-auto,
        .my#{$infix}-auto {
            margin-top: auto !important;
        }
        .mr#{$infix}-auto,
        .mx#{$infix}-auto {
            margin-right: auto !important;
        }
        .mb#{$infix}-auto,
        .my#{$infix}-auto {
            margin-bottom: auto !important;
        }
        .ml#{$infix}-auto,
        .mx#{$infix}-auto {
            margin-left: auto !important;
        }
    }
}